load TagBlock,ResetTabs,ListBlock,References,AttachData,INDIPanes,InsertPortrait,SourceButtons,TableTabs

! -------------- Start Template -----------------
GoSub INDIPanes,""
GoSub ResetTabs,0

! -------- Portrait
! #oldWidth defined in FAMPanes and #boxend in Insert Portrait
GoSub InsertPortrait,@OBJE,@_NOPOR

if #mainAll="no"
  ! --------- Birth and Death -----------
  show BIRT box
  showAll BIRT box

  newline
  if #vpos$>#boxend
    DisplayWidth #oldWidth
  endif
  show DEAT box
  showAll DEAT box

  ! To show existing individual events but none if no event,
  ! add one line for each (except RESI) like: 
  !if #vpos$>#boxend
  !  DisplayWidth #oldWidth
  !endif
  !ShowAll BURI

  ! To show existing individual events and blank fields if no event,
  ! add two lines for each (except RESI) like:
  !if #vpos$>#boxend
  !  DisplayWidth #oldWidth
  !endif
  !Show BAPM box
  !ShowAll BAPM box
else if #showBMD="yes"
  ! --------- Birth and Death -----------
  show BIRT box
  showAll BIRT box

  newline
  if #vpos$>#boxend
    DisplayWidth #oldWidth
  endif
  show DEAT box
  showAll DEAT box
endif

! --------- Parent links -----------
newline
if #vpos$>#boxend
  DisplayWidth #oldWidth
endif
#famLabelEnd=120
cell GroupBox,local("Parents")
  width -1
  NewLine -3
  Show FAMC
  ShowAll FAMC
EndGroup

! --------- Spouse/Family links -----------
newline
if #vpos$>#boxend
  DisplayWidth #oldWidth
endif
cell GroupBox,local("Spouses")
  width -1
  NewLine -3
  Show FAMS
  ShowAll FAMS 1
EndGroup

! stop waiting. should be enough
newline
DisplayWidth #oldWidth

if #mainAll="no"
  ! To show notes on the first page, uncomment these lines
  !if NOTE is here
  !  cell GroupBox,local("NOTE")
  !    width -1
  !    newline -3
  !    ShowAll NOTE,1
  !  EndGroup
  !endif

  hideexcess

else
  ! *************** EVENTS PANE ***************

  ! --------- Events and attributes --------------
  cell GroupBox,local("Events and Attributes")
    width -1

    newline -1
    #tstart=#vpos$
    gosub TableTabs,1
    if #oneTable="yes"
      ShowAll INDIEvntsAttrsOrdns
      
    else
      !hide BIRT,DEAT
      ShowAll INDIEvents
      ShowAll INDIOrdinances

      gosub TableTabs,2
      ShowAll RESI

      gosub TableTabs,0
      ShowAll INDIAttributes
    endif

    #lineSkip=#lineSkip$
    #cellSkip=#cellSkip$

    newline
    if #vpos$=#tstart
      newline -3
    endif
    cell LinkButton
    image "plus"
    set width 24 border no
    MenuLink "Attach Event/Attribute"
    help local("Click to add an event")

    cell LinkButton "-"
    image "minus"
    set width 24 border no
    MenuLink "Detach Event/Attribute/Link"
    help local("Click to remove an event")

    hskip 10
    cell LinkButton local("Copy Event")
    set border shadowlesssquare
    MenuLink "Copy Event"
    help local("Click to copy event with text selection bar")
    sizetofit 10

    hskip 3
    cell LinkButton local("Paste Event")
    set border shadowlesssquare
    MenuLink "Paste Event"
    help local("Click to paste previously copied event to this record")
    sizetofit 10
    
    hskip 3
    cell LinkButton local("Map")
    set border shadowlesssquare
    set ScriptLink "Maps/EventPlaces" ScriptType "system"
    help local("Click to map the events for this record")
    sizetofit 10

  EndGroup
  GoSub ResetTabs,0

  ! *************** MULTIMEDIA PANE ***************

  ! --------- OBJEs -----------
  Gosub TagBlock,"OBJE","Multimedia"

  ! *************** NOTES AND OTHER PANE ***************

  ! --------- NOTEs, SOURs, and _LOGs -----------
  #numSOURs=@count.SOUR
  gosub References,"_LOG"

  ! *************** ADDITIONAL DATA PANE ***************

  ! --------- ALIA, ASSO, SUBM, ---------------
  if ALIA|ASSO|SUBM|ANCI|DESI is here
    ClearTabs
    #assoTab=100
    SetTab #assoTab
    newline
    cell GroupBox,local("Associated Records")
      width -1
      newline
      ShowAll ALIA
      ShowAll ASSO
      ShowAll SUBM
      ClearTabs
      gosub ResetTabs,50
      ShowAll ANCI
      ShowAll DESI
    EndGroup
    GoSub ResetTabs,0
  endif

  ! --------- Attach links
  newline
  cell GroupBox,local("Attach")
    width -1
    newline -#lineSkip-3
    #lineSkip=2
    Show OBJE
    Show NOTE
    Show SOUR
    Show _LOG
    Show ALIA
    Show ASSO
    gosub AttachData
    GoSub SourceButtons,"true",#numSOURs
    newline 3
    hskip 2
  EndGroup
  #lineSkip=#lineSkip$

  ! -------- Additional Data ------------
  if more is true
    ClearTabs
    gosub ResetTabs,50
    cell GroupBox,local("Additional Data")
      width -1
      newline
      ShowAll CHAN
      ShowAll AFN
      ShowAll RFN
      ShowAll RIN
      ShowAll all
    EndGroup
  endif

  ! -------- Export -------------

  cell GroupBox,local("Export")
    width -1
    cell LinkButton ".ged"
    set ScriptLink "Export Data/ShareGEDCOMFile" ScriptType "system"
    set border shadowlesssquare
    sizetofit
  EndGroup

  optionalTag AFN,local(AFN)
  optionalTag RFN,local(RFN)
  optionalTag RIN,local(RIN)
  optionalTag REFN,local(REFN)
  optionalTag SUBM,local(SUBM)
  optionalTag ANCI,local(ANCI)
  optionalTag DESI,local(DESI)
  optionalTag,REFN,local("Keyword(s)"), ,"TYPE Keyword(s)"
endif
